package cn.SiFuLan.dao.impl;

import cn.SiFuLan.dao.IclassifDao;
import cn.SiFuLan.entity.brandEntity;
import cn.SiFuLan.entity.classifyEntity;
import cn.SiFuLan.utils.BaseDao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class classifDaoImpl extends BaseDao implements IclassifDao {
    @Override
    public List<classifyEntity> All() {
        String sql="SELECT Classid,Class_Name FROM classify";
        List<classifyEntity> list=new ArrayList<>();
        ResultSet rs= executeQuery(sql,null);
        while (true) {
            try {
                if (!rs.next()) break;
                classifyEntity b=new classifyEntity();
                b.setClassid(rs.getInt("Classid"));
                b.setClass_Name(rs.getString("Class_Name"));
                list.add(b);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        try {
            CloseAll(rs.getStatement().getConnection(),rs.getStatement(),rs);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
}
